<script>
  function checkMax(async){
    return check($("#maximum"),"labelmaximum","integer","For the maximum, please enter a positive integer",async);
  }
  function checkList(async){
    return check($("#integer-list"),"labelinteger-list","listofint","For the factors, please enter positive integers, space delimited",async);
  }
  function formValid(async){
      var cMax = checkMax(false);
      var cInts = checkList(false);
      if(true && cMax && cInts){
        return true;
      }
      else{
        $("#answer").html('');
        return false;
     }

  }
function processForm(){
      if(formValid(false)){
        var getData = '?maximum=' + $('#maximum').val() + '&integer-list=' + $('#integer-list').val();
        $.ajax({
          type: 'GET',
          dataType: 'json',
          url: '/answer-euler1' + getData,
          success: function(data){
            $("#answer").html(data);
          }
        });
	}
	else{
	$('#errorMessage').fadeIn();}

}

  $(document).ready(function () {
    $('#maximum').blur(function () { processForm(); } );
    $('#integer-list').blur(function () { processForm(); });
  });
</script>
    
    <h1>Euler Problem 1</h1>
    <form >
      <span id="labelmaximum">Maximum Integer</span><br />
      <input id="maximum" type='text' name='maximum' class='txt' />
      <br><br>
	<span id="labelinteger-list">Integers seperated by a single space, ex: 3 5 7</span><br />
      <input id="integer-list" type='text' name='integer-list' class='txt' />
    </form>
    <div id="answer"></div>


